package com.probiz.estore.common.model.product.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.product.Brand;
import com.probiz.estore.common.model.product.ProductType;
import com.probiz.estore.core.model.BaseObject;

/**
 * ProductTypeBrand Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class ProductTypeBrandTbl extends BaseObject implements Serializable {

    protected Integer productTypeBrandId;
	protected Integer sortOrder;
	protected ProductType productType;
	protected Brand brand;


	/**
	 * Default Empty Constructor for class ProductTypeBrand
	 */
	public ProductTypeBrandTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ProductTypeBrand
     *  @param in_productTypeBrandId id
	 */
	public ProductTypeBrandTbl (Integer in_productTypeBrandId) {
        this.setProductTypeBrandId(in_productTypeBrandId);
    }


    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }

    public Brand getBrand() {
        return brand;
    }

    public void setBrand(Brand brand) {
        this.brand = brand;
    }

    /**
	 * 	 * @return Integer
     * @hibernate.id column="productTypeBrandId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getProductTypeBrandId() {
		return this.productTypeBrandId;
	}
	
	/**
	 * Set the productTypeBrandId
	 */	
	public void setProductTypeBrandId(Integer aValue) {
		this.productTypeBrandId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getProductTypeId() {
		return this.getProductType()==null?null:this.getProductType().getProductTypeId();
	}
	
	/**
	 * Set the productTypeId
	 */	
	public void setProductTypeId(Integer aValue) {
	    if (aValue==null) {
	    	productType = null;
	    } else {
	        productType = new com.probiz.estore.common.model.product.ProductType(aValue);
	        productType.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getBrandId() {
		return this.getBrand()==null?null:this.getBrand().getBrandId();
	}
	
	/**
	 * Set the brandId
	 */	
	public void setBrandId(Integer aValue) {
	    if (aValue==null) {
	    	brand = null;
	    } else {
	        brand = new com.probiz.estore.common.model.product.Brand(aValue);
	        brand.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ProductTypeBrandTbl)) {
			return false;
		}
		ProductTypeBrandTbl rhs = (ProductTypeBrandTbl) object;
		return new EqualsBuilder()
				.append(this.productTypeBrandId, rhs.productTypeBrandId)
								.append(this.sortOrder, rhs.sortOrder)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.productTypeBrandId) 
								.append(this.sortOrder) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("productTypeBrandId", this.productTypeBrandId) 
								.append("sortOrder", this.sortOrder) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "productTypeBrandId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return productTypeBrandId;
	}

}